<template>
  <div class="edit-dialog">
    <el-dialog
      title="安排评审会议"
      :visible.sync="showArrangeMeetingDialog"
      width="628px"
      :before-close="handleClose"
      :close-on-click-modal="false"
      top="12"
      custom-class="dialog-box"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
      >
        <el-form-item label="评审地点" prop="reviewAddress">
          <el-input
            v-model="ruleForm.reviewAddress"
            maxlength="32"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getArrangeMeeting } from "@/api/manage/manage";
export default {
  name: "ArrangeMeeting",
  props: {
    showArrangeMeetingDialog: {
      type: Boolean,
      default: "",
    },
    type: {
      type: String,
      default: "",
    },
    proId: {
      type: String,
      default: "",
    },
  },
  inject: ["reload"],
  data() {
    return {
      rules: {
        daterange: [
          {
            type: "array",
            required: false,
            message: "请选择日期",
            trigger: ["blur", "change"],
          },
        ],
        reviewAddress: [
          { required: true, message: "请输入地点", trigger: ["blur"] },
        ],
      },
      ruleForm: {
        reviewTimeStart: ''
      },
      daterange: [], //时间
    };
  },
  methods: {
    /** 取消按钮 */
    handleClose() {
      this.$refs.ruleForm.resetFields();
      this.$emit("changeShowDialog", "false"); //调用父组件的自定义事件，并传值
    },
    /** 确定按钮 */
    submitForm() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          let data = {
            proId: this.proId,
            reviewAddress: this.ruleForm.reviewAddress,
            reviewTimeStart: this.ruleForm.reviewTimeStart,
            // reviewTimeEnd: this.ruleForm.daterange[1],
          };
          getArrangeMeeting(data).then((res) => {
            this.$refs.ruleForm.resetFields();
            this.$emit("changeShowDialog", "false");
            this.reload();
            console.log(res);
          });
        }
      });
    },
  },
};
</script>
